{extend name="public:base" /}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <div class="row search-form">
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <select name="status" class="form-control form-control-lg">
                                    <option value="-1">请选择状态</option>
                                    <option value="0" {:input(
                                    'status') == 0 ? 'selected' : ''}>待审核</option>
                                    <option value="1" {:input(
                                    'status') == 1 ? 'selected' : ''}>已审核</option>
                                    <option value="2" {:input(
                                    'status') == 2 ? 'selected' : ''}>已打款</option>
                                    <option value="3" {:input(
                                    'status') == 3 ? 'selected' : ''}>已驳回</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <button type="button" class="btn btn-primary btn-lg screen-btn">搜索</button>
                            </div>
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>银行卡信息</th>
                                <th>提现金额</th>
                                <th>提现类型</th>
                                <th>状态</th>
                                <th>驳回原因</th>
                                <th>审核时间</th>
                                <th>打款时间</th>
                                <th>申请时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                {if $vo.type == 1}
                                <td>{$vo.user_name} / {$vo.card_num} / {$vo.bank_name}</td>
                                {else /}
                                <td>-</td>
                                {/if}
                                <td>{$vo.profit}</td>
                                <td>{$vo.type == 1 ? '银行卡提现' : '微信提现'}</td>
                                <td>{$vo.status|doWithdrawStatus}</td>
                                <td>{$vo.reason}</td>
                                <td>{:timeFormat($vo.check_time)}</td>
                                <td>{:timeFormat($vo.pay_time)}</td>
                                <td>{:timeFormat($vo.create_time)}</td>
                                <td class="project-actions">
                                    {if $vo.type == 1}
                                    {if $vo.status == 0}
                                    <a href="{:url('doWithdraw', ['id' => $vo.id, 'status' => 1])}" class="btn btn-white btn-sm ajax-operate">
                                        <i class="iconfont icon-success"></i> 审核通过
                                    </a>
                                    <a href="javascript: void(0)" data-toggle="modal" data-target="#refuse" onclick="refuseId({$vo.id})" class="btn btn-white btn-sm">
                                        <i class="iconfont icon-refuse"></i> 驳回
                                    </a>
                                    {/if}
                                    {if $vo.status == 1}
                                    <a href="{:url('doWithdraw', ['id' => $vo.id, 'status' => 2])}" class="btn btn-white btn-sm ajax-operate">
                                        <i class="iconfont icon-news"></i> 已打款
                                    </a>
                                    {/if}
                                    {/if}
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        {if !empty($list)}{$list->render()}{/if}
                    </div>


                    <div class="modal inmodal" id="refuse" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content animated flipInY">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">
                                        <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                                    </button>
                                    <h4 class="modal-title">驳回</h4>
                                </div>
                                <div class="modal-body">
                                    <input type="text" class="form-control reason" placeholder="请输入驳回原因">
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-white close-model" data-dismiss="modal">关闭</button>
                                    <button type="button" class="btn btn-primary" id="confirmRefuse">确认修改</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>{/block}{block name="js"}
<script>
    var id;

    function refuseId(refuse_id) {
        id = refuse_id
    }

    $('#confirmRefuse').click(function () {
        var reason = $('.reason').val();
        $.post('/admin/manage/doWithdraw', {id, reason, status: 3}, res => {
            if (res.result == 1) {
                layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                    location.reload()
                })
            } else {
                layer.msg(res.msg, {icon: 2, time: 1000})
            }
        }, 'json')
    })
</script>{/block}